public class Login {
    //自定义异常类
    public String userName = "bit";
    public String passWord = "12345";

    public void loginInfo(String userName, String passWord) throws UserNameException, PassWordException {
        if(this.userName != userName) {
            //System.out.println("用户名错误");
            //return;
            throw new UserNameException();
        }
        if(this.passWord != passWord) {
            //System.out.println("密码错误");
            //return;
            throw new PassWordException();
        }
        System.out.println("登录成功");
    }

    public static void main(String[] args) {
        Login login = new Login();
        //login.loginInfo("bit","12345");
        try {
            login.loginInfo("bitt","12345");
        } catch (UserNameException e) {
            throw new RuntimeException(e);
        } catch (PassWordException e) {
            throw new RuntimeException(e);
        }
    }
}
